{
 "cells": [
  {
   "cell_type": "code",
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2024-09-30T08:57:11.180667Z",
     "start_time": "2024-09-30T08:57:00.750673Z"
    }
   },
   "source": [
    "import torch\n",
    "\n",
    "position = torch.arange(0, 10, dtype=torch.float).unsqueeze(1)\n",
    "position"
   ],
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tensor([[0.],\n",
       "        [1.],\n",
       "        [2.],\n",
       "        [3.],\n",
       "        [4.],\n",
       "        [5.],\n",
       "        [6.],\n",
       "        [7.],\n",
       "        [8.],\n",
       "        [9.]])"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 1
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-09-30T08:59:31.815918Z",
     "start_time": "2024-09-30T08:59:31.675343Z"
    }
   },
   "cell_type": "code",
   "source": [
    "import math\n",
    "d_model = 20\n",
    "div_term = torch.exp(torch.arange(0, d_model).float() * (-math.log(10000.0) / d_model))\n",
    "div_term"
   ],
   "id": "e9e8a407ad31be31",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tensor([1.0000e+00, 6.3096e-01, 3.9811e-01, 2.5119e-01, 1.5849e-01, 1.0000e-01,\n",
       "        6.3096e-02, 3.9811e-02, 2.5119e-02, 1.5849e-02, 1.0000e-02, 6.3096e-03,\n",
       "        3.9811e-03, 2.5119e-03, 1.5849e-03, 1.0000e-03, 6.3096e-04, 3.9811e-04,\n",
       "        2.5119e-04, 1.5849e-04])"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 2
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-09-30T09:04:31.326953Z",
     "start_time": "2024-09-30T09:04:31.321681Z"
    }
   },
   "cell_type": "code",
   "source": [
    "pe = position * div_term\n",
    "pe"
   ],
   "id": "d3548b61a0c7d1f6",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tensor([[0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,\n",
       "         0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,\n",
       "         0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,\n",
       "         0.0000e+00, 0.0000e+00],\n",
       "        [1.0000e+00, 6.3096e-01, 3.9811e-01, 2.5119e-01, 1.5849e-01, 1.0000e-01,\n",
       "         6.3096e-02, 3.9811e-02, 2.5119e-02, 1.5849e-02, 1.0000e-02, 6.3096e-03,\n",
       "         3.9811e-03, 2.5119e-03, 1.5849e-03, 1.0000e-03, 6.3096e-04, 3.9811e-04,\n",
       "         2.5119e-04, 1.5849e-04],\n",
       "        [2.0000e+00, 1.2619e+00, 7.9621e-01, 5.0238e-01, 3.1698e-01, 2.0000e-01,\n",
       "         1.2619e-01, 7.9621e-02, 5.0238e-02, 3.1698e-02, 2.0000e-02, 1.2619e-02,\n",
       "         7.9621e-03, 5.0238e-03, 3.1698e-03, 2.0000e-03, 1.2619e-03, 7.9621e-04,\n",
       "         5.0238e-04, 3.1698e-04],\n",
       "        [3.0000e+00, 1.8929e+00, 1.1943e+00, 7.5357e-01, 4.7547e-01, 3.0000e-01,\n",
       "         1.8929e-01, 1.1943e-01, 7.5357e-02, 4.7547e-02, 3.0000e-02, 1.8929e-02,\n",
       "         1.1943e-02, 7.5357e-03, 4.7547e-03, 3.0000e-03, 1.8929e-03, 1.1943e-03,\n",
       "         7.5357e-04, 4.7547e-04],\n",
       "        [4.0000e+00, 2.5238e+00, 1.5924e+00, 1.0048e+00, 6.3396e-01, 4.0000e-01,\n",
       "         2.5238e-01, 1.5924e-01, 1.0048e-01, 6.3396e-02, 4.0000e-02, 2.5238e-02,\n",
       "         1.5924e-02, 1.0048e-02, 6.3396e-03, 4.0000e-03, 2.5238e-03, 1.5924e-03,\n",
       "         1.0048e-03, 6.3396e-04],\n",
       "        [5.0000e+00, 3.1548e+00, 1.9905e+00, 1.2559e+00, 7.9245e-01, 5.0000e-01,\n",
       "         3.1548e-01, 1.9905e-01, 1.2559e-01, 7.9245e-02, 5.0000e-02, 3.1548e-02,\n",
       "         1.9905e-02, 1.2559e-02, 7.9245e-03, 5.0000e-03, 3.1548e-03, 1.9905e-03,\n",
       "         1.2559e-03, 7.9245e-04],\n",
       "        [6.0000e+00, 3.7857e+00, 2.3886e+00, 1.5071e+00, 9.5094e-01, 6.0000e-01,\n",
       "         3.7857e-01, 2.3886e-01, 1.5071e-01, 9.5094e-02, 6.0000e-02, 3.7857e-02,\n",
       "         2.3886e-02, 1.5071e-02, 9.5094e-03, 6.0000e-03, 3.7857e-03, 2.3886e-03,\n",
       "         1.5071e-03, 9.5094e-04],\n",
       "        [7.0000e+00, 4.4167e+00, 2.7868e+00, 1.7583e+00, 1.1094e+00, 7.0000e-01,\n",
       "         4.4167e-01, 2.7867e-01, 1.7583e-01, 1.1094e-01, 7.0000e-02, 4.4167e-02,\n",
       "         2.7868e-02, 1.7583e-02, 1.1094e-02, 7.0000e-03, 4.4167e-03, 2.7868e-03,\n",
       "         1.7583e-03, 1.1094e-03],\n",
       "        [8.0000e+00, 5.0477e+00, 3.1849e+00, 2.0095e+00, 1.2679e+00, 8.0000e-01,\n",
       "         5.0477e-01, 3.1849e-01, 2.0095e-01, 1.2679e-01, 8.0000e-02, 5.0477e-02,\n",
       "         3.1849e-02, 2.0095e-02, 1.2679e-02, 8.0000e-03, 5.0477e-03, 3.1849e-03,\n",
       "         2.0095e-03, 1.2679e-03],\n",
       "        [9.0000e+00, 5.6786e+00, 3.5830e+00, 2.2607e+00, 1.4264e+00, 9.0000e-01,\n",
       "         5.6786e-01, 3.5830e-01, 2.2607e-01, 1.4264e-01, 9.0000e-02, 5.6786e-02,\n",
       "         3.5830e-02, 2.2607e-02, 1.4264e-02, 9.0000e-03, 5.6786e-03, 3.5830e-03,\n",
       "         2.2607e-03, 1.4264e-03]])"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 7
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-09-30T09:04:59.016477Z",
     "start_time": "2024-09-30T09:04:59.002750Z"
    }
   },
   "cell_type": "code",
   "source": "pe.unsqueeze(0) ",
   "id": "65d902f34977cbc2",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tensor([[[0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,\n",
       "          0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,\n",
       "          0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,\n",
       "          0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00],\n",
       "         [1.0000e+00, 6.3096e-01, 3.9811e-01, 2.5119e-01, 1.5849e-01,\n",
       "          1.0000e-01, 6.3096e-02, 3.9811e-02, 2.5119e-02, 1.5849e-02,\n",
       "          1.0000e-02, 6.3096e-03, 3.9811e-03, 2.5119e-03, 1.5849e-03,\n",
       "          1.0000e-03, 6.3096e-04, 3.9811e-04, 2.5119e-04, 1.5849e-04],\n",
       "         [2.0000e+00, 1.2619e+00, 7.9621e-01, 5.0238e-01, 3.1698e-01,\n",
       "          2.0000e-01, 1.2619e-01, 7.9621e-02, 5.0238e-02, 3.1698e-02,\n",
       "          2.0000e-02, 1.2619e-02, 7.9621e-03, 5.0238e-03, 3.1698e-03,\n",
       "          2.0000e-03, 1.2619e-03, 7.9621e-04, 5.0238e-04, 3.1698e-04],\n",
       "         [3.0000e+00, 1.8929e+00, 1.1943e+00, 7.5357e-01, 4.7547e-01,\n",
       "          3.0000e-01, 1.8929e-01, 1.1943e-01, 7.5357e-02, 4.7547e-02,\n",
       "          3.0000e-02, 1.8929e-02, 1.1943e-02, 7.5357e-03, 4.7547e-03,\n",
       "          3.0000e-03, 1.8929e-03, 1.1943e-03, 7.5357e-04, 4.7547e-04],\n",
       "         [4.0000e+00, 2.5238e+00, 1.5924e+00, 1.0048e+00, 6.3396e-01,\n",
       "          4.0000e-01, 2.5238e-01, 1.5924e-01, 1.0048e-01, 6.3396e-02,\n",
       "          4.0000e-02, 2.5238e-02, 1.5924e-02, 1.0048e-02, 6.3396e-03,\n",
       "          4.0000e-03, 2.5238e-03, 1.5924e-03, 1.0048e-03, 6.3396e-04],\n",
       "         [5.0000e+00, 3.1548e+00, 1.9905e+00, 1.2559e+00, 7.9245e-01,\n",
       "          5.0000e-01, 3.1548e-01, 1.9905e-01, 1.2559e-01, 7.9245e-02,\n",
       "          5.0000e-02, 3.1548e-02, 1.9905e-02, 1.2559e-02, 7.9245e-03,\n",
       "          5.0000e-03, 3.1548e-03, 1.9905e-03, 1.2559e-03, 7.9245e-04],\n",
       "         [6.0000e+00, 3.7857e+00, 2.3886e+00, 1.5071e+00, 9.5094e-01,\n",
       "          6.0000e-01, 3.7857e-01, 2.3886e-01, 1.5071e-01, 9.5094e-02,\n",
       "          6.0000e-02, 3.7857e-02, 2.3886e-02, 1.5071e-02, 9.5094e-03,\n",
       "          6.0000e-03, 3.7857e-03, 2.3886e-03, 1.5071e-03, 9.5094e-04],\n",
       "         [7.0000e+00, 4.4167e+00, 2.7868e+00, 1.7583e+00, 1.1094e+00,\n",
       "          7.0000e-01, 4.4167e-01, 2.7867e-01, 1.7583e-01, 1.1094e-01,\n",
       "          7.0000e-02, 4.4167e-02, 2.7868e-02, 1.7583e-02, 1.1094e-02,\n",
       "          7.0000e-03, 4.4167e-03, 2.7868e-03, 1.7583e-03, 1.1094e-03],\n",
       "         [8.0000e+00, 5.0477e+00, 3.1849e+00, 2.0095e+00, 1.2679e+00,\n",
       "          8.0000e-01, 5.0477e-01, 3.1849e-01, 2.0095e-01, 1.2679e-01,\n",
       "          8.0000e-02, 5.0477e-02, 3.1849e-02, 2.0095e-02, 1.2679e-02,\n",
       "          8.0000e-03, 5.0477e-03, 3.1849e-03, 2.0095e-03, 1.2679e-03],\n",
       "         [9.0000e+00, 5.6786e+00, 3.5830e+00, 2.2607e+00, 1.4264e+00,\n",
       "          9.0000e-01, 5.6786e-01, 3.5830e-01, 2.2607e-01, 1.4264e-01,\n",
       "          9.0000e-02, 5.6786e-02, 3.5830e-02, 2.2607e-02, 1.4264e-02,\n",
       "          9.0000e-03, 5.6786e-03, 3.5830e-03, 2.2607e-03, 1.4264e-03]]])"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 8
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-09-30T09:39:02.090111Z",
     "start_time": "2024-09-30T09:39:02.087247Z"
    }
   },
   "cell_type": "code",
   "source": "print(1e4)",
   "id": "f0934f6875ddae83",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10000.0\n"
     ]
    }
   ],
   "execution_count": 9
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-09-30T09:49:36.995632Z",
     "start_time": "2024-09-30T09:49:36.992677Z"
    }
   },
   "cell_type": "code",
   "source": [
    "def function1(a=1, b=2):\n",
    "    print('function1')"
   ],
   "id": "e1d7e7d86ead74ad",
   "outputs": [],
   "execution_count": 10
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-09-30T09:49:47.790092Z",
     "start_time": "2024-09-30T09:49:47.434746Z"
    }
   },
   "cell_type": "code",
   "source": "function1(1,c=3)",
   "id": "e88ac528daa3a8df",
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "function1() got an unexpected keyword argument 'c'",
     "output_type": "error",
     "traceback": [
      "\u001B[1;31m---------------------------------------------------------------------------\u001B[0m",
      "\u001B[1;31mTypeError\u001B[0m                                 Traceback (most recent call last)",
      "Cell \u001B[1;32mIn[11], line 1\u001B[0m\n\u001B[1;32m----> 1\u001B[0m function1(\u001B[38;5;241m1\u001B[39m,c\u001B[38;5;241m=\u001B[39m\u001B[38;5;241m3\u001B[39m)\n",
      "\u001B[1;31mTypeError\u001B[0m: function1() got an unexpected keyword argument 'c'"
     ]
    }
   ],
   "execution_count": 11
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-11-19T06:07:33.056324Z",
     "start_time": "2024-11-19T06:07:33.052908Z"
    }
   },
   "cell_type": "code",
   "source": "28 * 9 + 84 + 24 + 48 + 120",
   "id": "7fb8f77cfc4da0c3",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "528"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 1
  },
  {
   "metadata": {},
   "cell_type": "code",
   "outputs": [],
   "execution_count": null,
   "source": "",
   "id": "6f945709c2b0dd0f"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
